package com.heima.user.controller.v1;

import com.heima.user.service.WorkflowService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

/**
 * 工作流控制器
 */
@RestController
@RequestMapping("/api/v1/workflow")
@Api(tags = "AI工作流接口")
@Slf4j
public class WorkflowController {

    @Autowired
    private WorkflowService workflowService;

    /**
     * 运行工作流
     *
     * @param response HTTP响应对象
     * @param query    查询内容
     * @param userId   用户ID
     */
    @ApiOperation("运行AI工作流")
    @CrossOrigin(origins = "*")
    @PostMapping("/run")
    public void runWorkflow(HttpServletResponse response,
                            @RequestParam("query") String query,
                            @RequestParam(value = "userId", required = false) Integer userId) {
        workflowService.runWorkflow(response, query, userId);
    }
}